package com.jn.server;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.swing.*;
import java.awt.*;

/**
 * @author 江南大学1033190417
 * @date 2022/4/7 14:23
 */
@SpringBootApplication
public class ServerApplication extends JFrame {

    private JButton start;
    private JButton quit;
    private JTextField serPort;//端口号
    private JTextField path;//指定路径


    public ServerApplication(String[] param) {
        super("马帅的网络服务器");
        Container container = getContentPane();
        container.setLayout(new FlowLayout());
        Font font = new Font("楷体", Font.BOLD, 24);

        JLabel l1 = new JLabel("端口号：");
        l1.setFont(font);
        serPort = new JTextField(20);
        serPort.setFont(font);
        container.add(l1);
        container.add(serPort);
        JLabel l2 = new JLabel("指定路径：");
        l2.setFont(font);
        path = new JTextField(20);
        path.setFont(font);
        container.add(l2);
        container.add(path);

        start = new JButton("开始");
        start.setFont(font);
        quit = new JButton("退出");
        quit.setFont(font);
        container.add(start);
        container.add(quit);


        start.addActionListener(
                e -> SpringApplication.run(ServerApplication.class,param)
        );
        setSize(500, 500);
        setVisible(true);
    }

    public static void main(String[] args) {
        ServerApplication index = new ServerApplication(args);
        index.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }

}
